home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 846 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: engnews1.Eng.Sun.COM!usenet
  2. From: phalpern@truffle.ultranet.com (Pablo Halpern)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: no operator bool()?
  5. Date: 25 Mar 1996 18:19:27 GMT
  6. Organization: UltraNet Communications, Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <3156d1c6.8268354@news.ultranet.com>
  9. References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com> <31470097.36C0@ix.netcom.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. X-Nntp-Posting-Host: truffle.ultranet.com
  12. X-Newsreader: Forte Agent .99d/16.182
  13. Content-Length: 1127
  14. X-Lines: 31
  15.  
  16. "Paul D. DeRocco" <pderocco@ix.netcom.com> wrote:
  17.  
  18. >>      while (bool(cin))
  19. >There's an awful lot of code out there that says "while (cin) ...", and 
  20. >no one wants to rewrite it all just to coax it through the new compiler. 
  21. >That's probably the reason.
  22.  
  23. Right, but that's not really my point. My point is that allowing the
  24. keyword "explicit" for conversion operators would make a lot of sense.
  25. If the committee ever did want to eliminate implicit conversion from
  26. istream to bool, then they could simply make it explicit. Sure, people
  27. would have to change their code, but at least the change would be
  28. mnemonic and readable. More importantly would be the addition of 
  29.  
  30.    template <class T> class auto_ptr {
  31.      ...
  32.      explicit operator bool() const;
  33.    };
  34.  
  35. This would be a clean syntax that would allow
  36.  
  37.    auto_ptr<foo> x;
  38.    while (bool(x))
  39.      ...
  40.  
  41. I shouldn't have confused the issue by using cin as my example.
  42. -------------------------------------------------------------
  43. Pablo Halpern                   phalpern@truffle.ultranet.com
  44.  
  45. I am self-employed. Therefore, my opinions *do* represent 
  46. those of my employer.
  47.  
  48.  
  49. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  50. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  51. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  52. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  53. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  54.